package com.huawei.hianalytics.f.f;

import com.huawei.hianalytics.f.b.c;
import com.huawei.hianalytics.f.g.k;
import com.huawei.hianalytics.g.b;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

public class q {
    private static q a;
    private String b;
    private Map<String, Map<String, List<c>>> c;

    public static class a implements com.huawei.hianalytics.i.a {
        private Map<String, List<c>> a;
        private String b;
        private String c;

        a(Map<String, List<c>> map, String str, String str2) {
            this.a = map;
            this.b = str;
            this.c = str2;
        }

        public void run() {
            b.b("UpgradeDataManager", "UpgradeEventsTask is running");
            for (Entry entry : this.a.entrySet()) {
                new c(com.huawei.hianalytics.a.b.n(), this.b, (c[]) ((List) entry.getValue()).toArray(new c[((List) entry.getValue()).size()]), this.c, "").a();
            }
        }
    }

    public static q a() {
        if (a == null) {
            b();
        }
        return a;
    }

    private static synchronized void b() {
        synchronized (q.class) {
            if (a == null) {
                a = new q();
            }
        }
    }

    private void b(String str) {
        Map map = (Map) this.c.get(str);
        if (map == null || map.size() <= 0) {
            b.b("UpgradeDataManager", "instanceData is null，not have this spKey data,or instanceData size == 0," + str);
            return;
        }
        k.a(new a(map, str, this.b));
        b.b("UpgradeDataManager", "remove instance data , spkey: " + str);
        this.c.remove(str);
    }

    public synchronized void a(String str) {
        if (this.c == null) {
            b.c("UpgradeDataManager", "upgradeData is null");
        } else if ("_default_config_tag".equals(str)) {
            b("_default_config_tag");
        } else {
            b(str + "-" + "oper");
            b(str + "-" + "maint");
            b(str + "-" + "diffprivacy");
        }
    }

    public void a(Map<String, Map<String, List<c>>> map, String str) {
        this.c = map;
        b.b("UpgradeDataManager", "upgradeData size: " + map.size());
        this.b = str;
    }
}
